﻿using System;
using System.Linq;
using System.Runtime.CompilerServices;
using UnityEngine;

[ExecuteInEditMode]
public class ModelVisual : MonoBehaviour
{
    [CompilerGenerated]
    private static Func<MeshRenderer, Bounds> <>f__am$cache2;
    public Bounds bounds;
    public Model model;

    private void LateUpdate()
    {
        if ((this.model != null) && this.model.isActiveAndEnabled)
        {
            base.transform.position = this.model.transform.position;
            base.transform.eulerAngles = this.model.transform.eulerAngles;
            base.transform.localScale = this.model.transform.localScale;
            base.transform.GetChild(0).localPosition = this.model.GetOffset();
        }
        else
        {
            UnityEngine.Object.DestroyImmediate(base.gameObject);
        }
    }

    private void OnEnable()
    {
        foreach (Transform transform in base.GetComponentsInChildren<Transform>())
        {
            transform.hideFlags = HideFlags.HideAndDontSave;
            transform.gameObject.hideFlags = HideFlags.HideAndDontSave;
        }
        if (<>f__am$cache2 == null)
        {
            <>f__am$cache2 = x => x.bounds;
        }
        this.bounds = base.GetComponentsInChildren<MeshRenderer>().Select<MeshRenderer, Bounds>(<>f__am$cache2).Merge();
    }
}

